package com.liliudong.rommath.config;

import cn.dev33.satoken.interceptor.SaInterceptor;
import cn.dev33.satoken.stp.StpInterface;
import com.liliudong.rommath.impl.StpInterfaceImpl;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * SaTokenConfigure
 *
 * @author ldli5
 * @classname SaTokenConfigure
 * @date 2024/6/18-8:59
 */
@Configuration
public class SaTokenConfigure implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 所有请求都被sa-token拦截
        registry.addInterceptor(new SaInterceptor())
                .addPathPatterns("/**");
    }

    @Bean
    public StpInterface stpInterface() {
        return new StpInterfaceImpl();
    }
}

